<template>
	<view class="ayi-page tab-page">
		<navigation :isBack="false" titleTintColor="#fff">
			<image slot="nav_topbar_title_img" style="height: 40px;" mode="aspectFit" src="/static/img/logo.png"></image>
			<text slot="iconfont" v-show="isShowSwiper" class="iconfont" @click="hideSlider()">&#xecaa;</text>
			<text slot="iconfont" v-show="!isShowSwiper" class="iconfont" @click="hideSlider()">&#xecab;</text>
		</navigation>
		<swiper
			class="swiper"
			v-show="isShowSwiper"
			indicator-color="rgba(255,255,255,1)"
			indicator-active-color="rgba(242,68,57,1)"
			:indicator-dots="indicatorDots"
			:autoplay="autoplay"
			:interval="interval"
			:duration="duration"
		>
			<swiper-item class="swiper-item" v-for="(item, index) in bannerArr" :key="index">
				<view><img class="s-i-img" :src="item.img" /></view>
			</swiper-item>
		</swiper>
		<view class="home-notice">
			<i class="iconfont h-n-icon" style="font-size: 40rpx;">&#xe609;</i>
			<view class="h-n-content"><rich-text class="notice-rich-text" :nodes="noticeArr"></rich-text></view>
		</view>

		<view class="third-menu-contain">
			<view class="t-m-c-item" @click="thirdMenu(0)">
				<image class="img-img" mode="aspectFit" v-show="thirdStatus == 0" src="/static/icon/index_tab1_active.png"></image>
				<image class="img-img" mode="aspectFit" v-show="thirdStatus != 0" src="/static/icon/index_tab1_default.png"></image>
			</view>
			<view class="t-m-c-item" @click="thirdMenu(1)">
				<image class="img-img" mode="aspectFit" v-show="thirdStatus == 1" src="/static/icon/index_tab2_active.png"></image>
				<image class="img-img" mode="aspectFit" v-show="thirdStatus != 1" src="/static/icon/index_tab2_default.png"></image>
			</view>
			<view class="t-m-c-item" @click="thirdMenu(2)">
				<image class="img-img" mode="aspectFit" v-show="thirdStatus == 2" src="/static/icon/index_tab3_active.png"></image>
				<image class="img-img" mode="aspectFit" v-show="thirdStatus != 2" src="/static/icon/index_tab3_default.png"></image>
			</view>
			<view class="t-m-c-item" @click="thirdMenu(4)">
				<image class="img-img" mode="aspectFit" v-show="thirdStatus == 4" src="/static/icon/index_tab5_active.png"></image>
				<image class="img-img" mode="aspectFit" v-show="thirdStatus != 4" src="/static/icon/index_tab5_default.png"></image>
			</view>
			<view class="t-m-c-item" @click="thirdMenu(3)">
				<image class="img-img" mode="aspectFit" v-show="thirdStatus == 3" src="/static/icon/index_tab4_active.png"></image>
				<image class="img-img" mode="aspectFit" v-show="thirdStatus != 3" src="/static/icon/index_tab4_default.png"></image>
			</view>
		</view>
		<!-- 体育竞技 -->
		<view v-show="thirdStatus == 1">
			<view class="home-tab-menu">
				<view class="h-t-m-item" @click="sportType(1)" :class="{ active: isSportAG }">
					<image class="item-select-img" v-show="isSportAG" mode="aspectFit" src="/static/img/index_page_tab_1.png"></image>
					<text class="h-itme-tit" v-show="!isSportAG">AG体育</text>
				</view>
				<view class="h-t-m-item" :class="{ active: isSportSBO }" @click="sportType(0)">
					<image class="item-select-img" v-show="isSportSBO" mode="aspectFit" src="/static/img/index_page_tab_4.png"></image>
					<text class="h-itme-tit" v-show="!isSportSBO">利己SBO</text>
				</view>
			</view>
			<view class="sport-item-contain" v-show="isSportAG">
				<view class="sport-item" v-for="(item, index) in sportList" :key="index">
					<image class="sport-item-img" mode="aspectFit" :src="item.cover" @click="goSportsEventsUrl(item.platformId, item.canDemo, item.platform_name)"></image>
				</view>
			</view>
			<view class="sport-item-contain" v-show="isSportSBO">
				<view class="sport-item" v-for="(item, index) in sportSBOList" :key="index">
					<image class="sport-item-img" mode="aspectFit" :src="item.cover" @click="goSportBooksUrl(item.canDemo)"></image>
				</view>
			</view>
		</view>
		<!-- 真人游戏 -->
		<view v-show="thirdStatus == 2">
			<view class="entertainment-item-contain">
				<view class="entertainment-item" v-for="(item, index) in entertainment" :key="index">
					<image @click="goEntertainmentUrl(item.platformId, item.canDemo, item.platform_name)" class="entertainment-item-img" mode="aspectFit" :src="item.cover"></image>
				</view>
			</view>
		</view>
		<!-- 电子游戏 -->
		<view v-show="thirdStatus == 3">
			<view class="home-tab-menu">
				<view class="h-t-m-item" @click="onElecGameType(1)" :class="{ active: isEleGame }">
					<image class="item-select-img" mode="aspectFit" v-show="isEleGame" src="/static/img/index_page_tab_2.png"></image>
					<text class="h-itme-tit" v-show="!isEleGame">AG电子</text>
				</view>
				<view class="h-t-m-item" @click="onElecGameType(2)" :class="{ active: isEleGameTwo }">
					<image class="item-select-img" v-show="isEleGameTwo" mode="aspectFit" src="/static/img/index_page_tab_3.png"></image>
					<text class="h-itme-tit" v-show="!isEleGameTwo">AG街机</text>
				</view>
			</view>
			<view class="ele-banner" v-for="(item, index) in electronicGameSp" :key="index">
				<image
					@click="goElectronicGameUrl(item.platform_id, item.ng_game_code, item.canDemo, item.platform_name)"
					class="ele-banner-img"
					mode="aspectFit"
					:src="item.image"
				></image>
			</view>
			<view class="ele-item-contain">
				<view
					class="ele-item"
					v-for="(item, index) in electronicGame"
					:key="index"
					@click="goElectronicGameUrl(item.platform_id, item.ng_game_code, item.canDemo, item.platform_name)"
				>
					<image class="ele-item-img" mode="aspectFit" :src="item.image"></image>
					<text>{{ item.name }}</text>
				</view>
			</view>
		</view>
		<!-- 开元棋牌游戏 -->
		<view v-show="thirdStatus == 4">
			<view class="home-tab-menu">
				<view class="h-t-m-item active"><image class="item-select-img" mode="aspectFit" src="/static/img/index_page_tab_8.png"></image></view>
				<view class="h-t-m-item"></view>
			</view>
			<view class="ky-banner"><image @click="goKYGameUrl(0)" class="ky-banner-img" mode="aspectFit" src="/static/img/ky_game.jpg"></image></view>
			<view class="ky-item-contain">
				<view class="ky-item" v-for="(item, index) in KYData" :key="index" @click="goKYGameUrl(item.canDemo, item.kindId)">
					<image class="ky-item-img" mode="aspectFit" :src="item.imageUrl"></image>
				</view>
			</view>
		</view>
		<!-- 显示彩票 -->
		<view v-show="thirdStatus == 0">
			<view class="home-tab-menu">
				<view class="h-t-m-item" @click="switchMenuTab(0)" :class="showMenu == 0 ? 'active' : ''">
					<image class="item-select-img" mode="aspectFit" v-show="showMenu == 0" src="/static/img/index_page_tab_6.png"></image>
					<text class="h-itme-tit" v-show="showMenu != 0">热门彩种</text>
				</view>
				<view class="h-t-m-item" @click="switchMenuTab(1)" :class="showMenu == 1 ? 'active' : ''">
					<image class="item-select-img" mode="aspectFit" v-show="showMenu == 1" src="/static/img/index_page_tab_5.png"></image>
					<text class="h-itme-tit" v-show="showMenu != 1">全部彩种</text>
				</view>
				<view class="h-t-m-item" @click="switchMenuTab(2)" :class="showMenu == 2 ? 'active' : ''">
					<image class="item-select-img" v-show="showMenu == 2" mode="aspectFit" src="/static/img/index_page_tab_7.png"></image>
					<text class="h-itme-tit" v-show="showMenu != 2">我的关注</text>
				</view>
			</view>
			<view class="home-menu-grid">
				<view class="hot" :class="showMenu == 0 ? 'active' : ''">
					<uni-grid :column="2" :show-border="false">
						<uni-grid-item style="width: 50%;" v-for="(item, index) in lot" :key="index" :class="index % 2 == 0 ? 'menu-right-border' : ''">
							<homeMenuItem :keyCode="item.key" :lotteryId="item.lotteryId" :timer="item.closeTime" :lotName="item.name" :imgSrc="url + item.img"></homeMenuItem>
						</uni-grid-item>
					</uni-grid>
				</view>
				<view class="hot" :class="showMenu == 1 ? 'active' : ''">
					<uni-grid :column="2" :show-border="false">
						<uni-grid-item style="width: 50%;" v-for="(item, index) in lot1" :key="index" :class="index % 2 == 0 ? 'menu-right-border' : ''">
							<homeMenuItem :keyCode="item.key" :lotteryId="item.lotteryId" :timer="item.closeTime" :lotName="item.name" :imgSrc="url + item.img"></homeMenuItem>
						</uni-grid-item>
					</uni-grid>
				</view>
				<view class="hot" :class="showMenu == 2 ? 'active' : ''">
					<uni-grid :column="2" :show-border="false">
						<uni-grid-item style="width: 50%;" v-for="(item, index) in lot2" :key="index" :class="index % 2 == 0 ? 'menu-right-border' : ''">
							<homeMenuItem :keyCode="item.key" :lotteryId="item.lotteryId" :timer="item.closeTime" :lotName="item.name" :imgSrc="url + item.img"></homeMenuItem>
						</uni-grid-item>
					</uni-grid>
				</view>
			</view>
		</view>
		<tabbarMask></tabbarMask>
	</view>
</template>

<script>
import { Tools, Config, URL, Net, VueTools } from '@/common/tools.js';
import uniGrid from '@/components/uni-grid/uni-grid.vue';
import uniGridItem from '@/components/uni-grid/uni-grid-item.vue';
import homeMenuItem from '@/components/home-grid-item.vue';
import tabbarMask from '@/components/tabbar-mask.vue';

import navigation from '@/components/navigation.vue';
import Tabbar from '@/components/tabbar.vue';
export default {
	components: { uniGrid, uniGridItem, homeMenuItem, navigation, Tabbar, tabbarMask },
	data() {
		return {
			indicatorDots: true,
			autoplay: true,
			interval: 2000,
			duration: 500,
			bannerArr: [], //滚动的图片
			lot: [], //热门彩种
			lot1: [], //所有彩种
			lot2: [], //已经存储的彩种
			url: Config.URL,
			showMenu: 1,
			allTime: {},
			isClearTimeOut: false,
			clearTimeOutArr: [],
			isShowMask: true,
			noticeArr: '', //公告的数据
			noticeTimer: '', //公告滚动的计时器
			isShowSwiper: true, //是否显示banner
			//第三方入口相关
			thirdStatus: 0,
			entertainment: [], //真人游戏的数据列表
			electronicGame: [], //游戏的列表数据(电子游戏)
			isEleGame: true, //是否选中电子游戏
			electronicGameSp: [],
			electronicGameTwo: [], //游戏列表的数据(街机)
			isEleGameTwo: false, //是否选中街机
			sportList: [], //AG体育的数据
			sportSBOList: [], //利己SBO的数据
			isSportAG: true, //默认选中AG体育
			isSportSBO: false, //选中利己SBO
			KYData: [], //开元棋牌游戏列表
			balance: 0, //平台的总可用余额
			listInfo: [], //其他平台的可用余额
			inputVal: '', //输入可转的树
			ng_game_code: '' //第三方的游戏标识
		};
	},
	mounted() {
		let that = this;
		this.$store.commit('setTabbarIndex', 3);
		uni.$on('startMenuTimer', function() {
			that.timeNet();
			uni.$emit('startTimer');
		});
		uni.$on('isClearTimeOut', function(data) {
			that.clearTimeoutFun();
			that.isClearTimeOut = data.isClear;
		});
	},
	onLoad() {
		this.getSliderData();
		this.getMenuData();
		this.noticeData();
	},
	onShow() {
		console.log('首页的显示！！！！');
	},
	onHide() {
		console.log('首页的隐藏！！！！ ');
	},
	methods: {
		getSliderData() {
			//获取首页滚屏
			let that = this;
			Net.ayiHttp(
				URL.USER_BANNER,
				'',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = Tools.aesDecodeToJson(res.data);
						that.bannerArr = data;
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		getMenuData() {
			//获取菜单
			let that = this;
			Net.ayiHttp(
				URL.USER_MAIN_HALL,
				'',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = Tools.aesDecodeToJson(res.data);
						//将菜单数据给存储下来
						VueTools.setStorageSync(Config.ALL_LOT_STORE_KEY, data);
						console.log('处理好了的', data);
						for (let tempData in data.lots) {
							data.lots[tempData]['closeTime'] = '';
							that.lot1.push(data.lots[tempData]);
							if (data.lots[tempData].type_code == 1) {
								that.lot.push(data.lots[tempData]);
							}
							// that.store.get(Config.IS_LOGIN_STORE_KEY).then(data => {
							// 	if (!ToolService.isEmpty(data)) {
							// 		//未登录进行登陆
							// 		if (data.lots[tempData].is_follow == 1) {
							// 			that.lots2.push(data.lots[tempData]);
							// 		}
							// 	}
							// });
						}
						console.log('热门:', that.lot);
						that.timeNet();
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
					uni.stopPullDownRefresh();
				},
				function(err) {
					console.log('error:', err);
					uni.stopPullDownRefresh();
				}
			);
		},
		switchMenuTab(index) {
			this.showMenu = index;
		},
		timer() {
			let that = this;
			that.clearTimeoutFun();
			let tempTimer = setTimeout(function() {
				clearTimeout(tempTimer);
				that.clearTimeoutFun();
				if (!that.isClearTimeOut) {
					uni.$emit('clearMenuTimer');
					that.timeNet();
					uni.$emit('startTimer');
				}
			}, 10000);
			this.clearTimeOutArr.push(tempTimer);
		},
		clearTimeoutFun() {
			for (let item in this.clearTimeOutArr) {
				clearTimeout(this.clearTimeOutArr[item]);
			}
			this.clearTimeOutArr = [];
		},
		timeNet() {
			//获取彩种菜单的时间
			let that = this;
			Net.ayiHttp(
				URL.USER_TIME,
				'',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let tt = Tools.aesDecodeToJson(res.data);
						that.allTime = tt;
						console.log('所有时间:', tt);
						//热门彩种的时间处理
						for (let t1 in that.lot) {
							that.lot[t1]['closeTime'] = '';
							for (let t11 in tt.times) {
								if (that.lot[t1].key == t11) {
									that.lot[t1]['closeTime'] = tt.times[t11] - tt.now;
								}
							}
						}
						//所有彩种时间处理
						for (let t1 in that.lot1) {
							that.lot1[t1]['closeTime'] = '';
							for (let t11 in tt.times) {
								if (that.lot1[t1].key == t11) {
									that.lot1[t1]['closeTime'] = tt.times[t11] - tt.now;
								}
							}
						}
						//我的关注的时间处理
						// for (let t1 in that.lot2) {
						// 	that.lots2[t1]['closeTime'] = '';
						// 	for (let t11 in tt.times) {
						// 		if (that.lot2[t1].key == t11) {
						// 			that.lot2[t1]['closeTime'] = tt.times[t11] - tt.now;
						// 		}
						// 	}
						// }
						that.timer();
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		toLotterDetail(code, lotName, lotteryId) {
			let that = this;
			uni.$emit('clearMenuTimer');
			uni.$emit('isClearTimeOut', { isClear: true });
			uni.navigateTo({
				url: '/pages/home/lotdetail/lotdetail?code=' + code + '&name=' + lotName + '&lotteryId=' + lotteryId,
				complete: () => {
					that.$store.commit('setTabbarIndex', -1);
				}
			});
		},
		/**
		 * 首页的公共数据
		 */
		noticeData() {
			let that = this;
			Net.ayiHttp(
				URL.USER_CONTENT,
				'{}',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = Tools.aesDecodeToJson(res.data);
						console.log(data);
						that.noticeArr = '';
						if (Tools.isEmpty(data + '') || Tools.isEmpty(data)) {
							that.noticeArr = '';
						} else {
							let tempArr = [];
							for (let item in data) {
								tempArr[item] = data[item]['content'];
							}
							that.noticeArr = tempArr.join('');
							that.start();
						}
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		start() {
			this.noticeTimer = setInterval(() => {
				let start = this.noticeArr.substring(0, 1);
				let end = this.noticeArr.substring(1);
				this.noticeArr = end + start;
			}, 250);
		},
		hideSlider() {
			if (this.isShowSwiper) {
				this.isShowSwiper = false;
			} else {
				this.isShowSwiper = true;
			}
		},
		thirdMenu(index) {
			if (index == 2 && this.thirdStatus != index) {
				//真人游戏
				if (this.entertainment.length <= 0) {
					this.getEntertainmentList();
				}
			} else if (index == 3 && this.thirdStatus != index) {
				//电子游戏
				if (this.isEleGame) {
					//电子
					this.getElectronicGameList();
				} else {
					//街机
					this.getElectronicGameList(2);
				}
			} else if (index == 1 && this.thirdStatus != index) {
				//体育竞技
				if (this.isSportAG) {
					//AG体育
					if (this.sportList.length <= 0) {
						this.getSportsEventsList();
					}
				}
				if (this.isSportSBO) {
					//利己SBO
					if (this.sportSBOList.length <= 0) {
						this.getSportsBookList();
					}
				}
			} else if (index == 4 && this.thirdStatus != index) {
				//开元棋牌
				if (this.KYData.length <= 0) {
					this.getKyGetShowList();
				}
			}
			this.thirdStatus = parseInt(index);
		},
		/**
		 * 获取AG体育的列表
		 */
		getSportsEventsList() {
			let that = this;
			Net.ayiHttp(
				URL.THIRD_GETSPORTSEVENTSLIST,
				'',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = Tools.aesDecodeToJson(res.data);
						if (!Tools.isEmpty(data)) {
							that.sportList = data;
						}
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		goSportsEventsUrl(platform_id, canDemo, platformName = '') {
			let that = this;
			let isTestPlay = false;
			let isLogin = true;
			if (Tools.isEmpty(VueTools.getStorageSync(Config.IS_LOGIN_STORE_KEY))) {
				isLogin = false;
			}
			if (!isLogin) {
				this.navigateToSigleUrl('/pages/my/login/login');
				return;
			}
			if (VueTools.getStorageSync(Config.ROLE_KEY) == '2') {
				isTestPlay = true;
			}
			if (isTestPlay) {
				if (canDemo == '1' || canDemo == 1) {
					//支持试玩且账号是试玩账号
					that.getSportsEventsUrlNet(platform_id, 1);
					return;
				} else {
					VueTools.toastNo('暂不支持试玩');
				}
			} else {
				//  that.eventS.publish("thirdWinShow",that.balance,true,platformName,that.getMaxPlatformBalance(platform_id),platform_id,3);
			}
		},
		/**
		 * 获取AG体育的数据
		 */
		getSportsEventsUrlNet(platformId, demo) {
			let that = this;
			let obj = '{"platform_id":"' + platformId + '","demo":"' + demo + '"}';
			Net.ayiHttp(
				URL.THIRD_GETSPORTSEVENTSURL,
				obj,
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let temp = res.data;
						console.log('体育竞技需要跳转的链接--', temp);
						if (!Tools.isEmpty(temp)) {
							//todo  app和h5的页面跳转
						}
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},

		/**
		 * 获取真人游戏列表
		 */
		getEntertainmentList() {
			let that = this;
			Net.ayiHttp(
				URL.THIRD_GETENTERTAINMENTPLAYLIST,
				'{}',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						let data = Tools.aesDecodeToJson(res.data);
						if (!Tools.isEmpty(data)) {
							that.entertainment = data;
						}
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		goEntertainmentUrl(platformId, canDemo, platformName = '') {
			let that = this;
			let isTestPlay = false;
			let isLogin = true;
			if (Tools.isEmpty(VueTools.getStorageSync(Config.IS_LOGIN_STORE_KEY))) {
				isLogin = false;
			}
			if (!isLogin) {
				this.navigateToSigleUrl('/pages/my/login/login');
				return;
			}
			if (VueTools.getStorageSync(Config.ROLE_KEY) == '2') {
				isTestPlay = true;
			}

			if (isTestPlay) {
				if (canDemo == '1' || canDemo == 1) {
					//支持试玩且账号是试玩账号
					that.goEntertainmentUrlNet(platformId, 1);
					return;
				} else {
					VueTools.toastNo('暂不支持试玩');
				}
			} else {
				//that.eventS.publish('thirdWinShow', that.balance, true, platformName, that.getMaxPlatformBalance(platformId), platformId, 1);
			}
		},
		goEntertainmentUrlNet(platformId, demo) {
			let that = this;
			let obj = '{"platform_id":"' + platformId + '","demo":"' + demo + '"}';
			Net.ayiHttp(
				URL.THIRD_GETENTERTAINMENTPLAYURL,
				obj,
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						let temp = res.data;
						console.log('真人游戏需要跳转的链接--', temp);
						if (!Tools.isEmpty(temp)) {
							//todu 链接的一个跳转
						}
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		/**
		 * 获取电子游戏的列表
		 */
		getElectronicGameList(type = 1) {
			let that = this;
			let obj = '{"type":"' + type + '"}';
			Net.ayiHttp(
				URL.THIRD_GETELECTRONICGAMELIST,
				obj,
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = Tools.aesDecodeToJson(res.data);
						if (!Tools.isEmpty(res)) {
							that.electronicGame = data.list;
							that.electronicGameSp = data.alone;
						}
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		/**
		 * 第三方的电子游戏的跳转
		 */
		goElectronicGameUrl(platform_id, ng_game_code, canDemo, platformName = '') {
			let that = this;
			let isTestPlay = false;
			let isLogin = true;
			if (Tools.isEmpty(VueTools.getStorageSync(Config.IS_LOGIN_STORE_KEY))) {
				isLogin = false;
			}
			if (!isLogin) {
				this.navigateToSigleUrl('/pages/my/login/login');
				return;
			}
			if (VueTools.getStorageSync(Config.ROLE_KEY) == '2') {
				isTestPlay = true;
			}
			this.ng_game_code = ng_game_code;
			if (isTestPlay) {
				if (canDemo == '1' || canDemo == 1) {
					//支持试玩且账号是试玩账号
					that.goElectronicGameUrlNet(platform_id, ng_game_code, 1);
					return;
				} else {
					VueTools.toastNo('暂不支持试玩');
				}
			} else {
				//  that.eventS.publish("thirdWinShow",that.balance,true,platformName,that.getMaxPlatformBalance(platform_id),platform_id,2);
			}
		},
		goElectronicGameUrlNet(platform_id, ng_game_code, demo) {
			let that = this;
			let obj = '{"platform_id":"' + platform_id + '","ng_game_code":"' + ng_game_code + '","demo":"' + demo + '"}';
			Net.ayiHttp(
				URL.THIRD_GETELECTRONICGAMEURL,
				obj,
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let temp = res.data;
						console.log('游戏需要跳转的链接--', temp);
						if (!Tools.isEmpty(temp)) {
							//todo去跳转页面
						}
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		/**
		 * 选中是AG电子还是AG街机
		 */
		onElecGameType(type) {
			if (type == 1) {
				if (this.isEleGameTwo) {
					this.getElectronicGameList();
				}
				this.isEleGame = true;
				this.isEleGameTwo = false;
			} else {
				if (this.isEleGame) {
					this.getElectronicGameList(2);
				}
				this.isEleGame = false;
				this.isEleGameTwo = true;
			}
		},
		sportType(type) {
			if (type == 1) {
				//AG体育
				if (this.sportList.length <= 0) {
					this.getSportsEventsList();
				}
				this.isSportAG = true;
				this.isSportSBO = false;
			} else {
				//利己SBO
				if (this.sportSBOList.length <= 0) {
					this.getSportsBookList();
				}
				this.isSportAG = false;
				this.isSportSBO = true;
			}
		},
		/**
		 * 开元棋牌游戏列表
		 */
		getKyGetShowList() {
			let that = this;
			Net.ayiHttp(
				URL.THIRD_KYGAME_GETSHOWLIST,
				'{}',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = res.data;
						if (!Tools.isEmpty(data)) {
							that.KYData = data;
						}
						console.log('===========开元棋牌游戏列表:', res);
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		/**
		 * 跳转到开元链接
		 * @param canDemo 是否支持试玩
		 * @param kindId 开元棋牌的id
		 */
		goKYGameUrl(canDemo, kindId = 0) {
			let that = this;
			let isTestPlay = false;
			let isLogin = true;
			if (Tools.isEmpty(VueTools.getStorageSync(Config.IS_LOGIN_STORE_KEY))) {
				isLogin = false;
			}
			if (!isLogin) {
				this.navigateToSigleUrl('/pages/my/login/login');
				return;
			}
			if (VueTools.getStorageSync(Config.ROLE_KEY) == '2') {
				isTestPlay = true;
			}
			that.kindId = kindId;
			if (isTestPlay) {
				//试玩
				VueTools.toastNo('暂不支持试玩');
			} else {
				//that.eventS.publish("thirdWinShow",that.balance,true,'开元棋牌',that.getMaxPlatformBalance('ky'),'ky',5);
				console.log('转化并跳转到ky页面');
			}
		},
		/**
		 * 跳转到开元的真实链接
		 */
		goKYGameUrlNet(kindId, money) {
			let that = this;
			Net.ayiHttp(
				URL.THIRD_KYGAME_GETCHESSGAMESURL,
				'{"kindId":"' + kindId + '","money":"' + money + '"}',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = res.data;
						if (!Tools.isEmpty(data)) {
							//跳转到页面
						}
						console.log('开元棋牌游戏需要跳转的链接--', data);
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		/**
		 * 获取利己SBO体育的列表
		 */
		getSportsBookList() {
			let that = this;
			Net.ayiHttp(
				URL.THIRD_GETSPORTSBOOKLIST,
				'{}',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = Tools.aesDecodeToJson(res.data);
						if (!Tools.isEmpty(data)) {
							that.sportSBOList = data;
						}
						console.log('===========第三方体育竞技SBO列表数据:', data);
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		},
		goSportBooksUrl(canDemo) {
			let that = this;
			let isTestPlay = false;
			let isLogin = true;
			if (Tools.isEmpty(VueTools.getStorageSync(Config.IS_LOGIN_STORE_KEY))) {
				isLogin = false;
			}
			if (!isLogin) {
				this.navigateToSigleUrl('/pages/my/login/login');
				return;
			}
			if (VueTools.getStorageSync(Config.ROLE_KEY) == '2') {
				isTestPlay = true;
			}
			if (isTestPlay) {
				//试玩
				VueTools.toastNo('暂不支持试玩');
			} else {
				// that.eventS.publish("thirdWinShow",that.balance,true,'利己SBO',that.getMaxPlatformBalance('sbo'),'sbo',4);
			}
		},
		goSportBooksUrlNet() {
			let that = this;
			Net.ayiHttp(
				URL.THIRD_GETSPORTSBOOKURL,
				'{}',
				function(res) {
					if (res.code == Config.SUCCESS_CODE) {
						//成功的逻辑
						let data = res.data;
						console.log('体育竞技SBO需要跳转的链接--', data);
						if (!Tools.isEmpty(data)) {
							//todo跳转到浏览器
						}
					} else if (res.code == Config.FAIL_CODE) {
						VueTools.toastNo(res.message);
					} else if (res.code == Config.LOGIN_CODE) {
						uni.navigateTo({
							url: '/pages/my/login/login'
						});
					}
				},
				function(err) {
					console.log('error:', err);
				}
			);
		}
	},
	onUnload() {
		uni.$off('startMenuTimer');
		uni.$off('isClearTimeOut');
		clearInterval(this.noticeTimer);
	},
	filters: {
		countdown: function(value, isHideHour = false) {
			if (Tools.isEmpty(value)) {
				return '已封盘';
			} else {
				if (isHideHour == true) {
					return Tools.formateTime(value, true);
				}
				return Tools.formateTime(value);
			}
		}
	},
	onTabItemTap(option) {
		let lotterParams = VueTools.getStorageSync(Config.LOTTER_DETAIL_PARAMS);
		if (!Tools.isEmpty(lotterParams) && !Tools.isEmpty(lotterParams.code) && !Tools.isEmpty(lotterParams.name)) {
			this.toLotterDetail(lotterParams.code, lotterParams.name, lotterParams.lotteryId);
			return;
		}
		if (this.$store.state.tabbar_now_index != 2 || this.$store.state.tabbar_now_index != '2') {
			// #ifdef APP-PLUS
			this.Tab.getInstance().show(false);
			// #endif
			this.$store.commit('setTabbarIndex', option.index);
			uni.$emit('clearMenuTimer');
			uni.$emit('isClearTimeOut', { isClear: true });
			uni.$emit('startMenuTimer');
			uni.$emit('isClearTimeOut', { isClear: false });
		}
	},
	onPullDownRefresh() {
		this.getMenuData();
	}
};
</script>

<style lang="scss">
.swiper {
	height: 300rpx;
}
.swiper-item {
	.s-i-img {
		width: 750rpx;
	}
}
.home-notice {
	height: 40rpx;
	padding: 0rpx 20rpx;
	display: flex;
	line-height: 40rpx;
	background: $wlh-home-notice-bg;
	.h-n-icon {
		color: #fff;
	}
	.h-n-content {
		width: 100%;
		overflow: hidden;
		font-size: 24rpx;
		display: flex;
		flex-direction: row;
		height: 40rpx;
		.notice-rich-text {
			color: #fff;
		}
	}
}
//有第三方菜单入口
.third-menu-contain {
	height: 152rpx;
	padding: 10rpx;
	border-bottom: 1px solid #e8e9ec;
	margin-bottom: 4rpx;
	display: flex;
	flex-direction: row;
	background: url('/static/img/index_play_bg.jpg') no-repeat;
	.t-m-c-item {
		width: 182.5rpx;
		height: 100%;
		display: flex;
		flex-direction: column;
		font-size: 12px;
		font-weight: bold;
		color: rgb(246, 87, 66);
		justify-content: center;
		align-items: center;
		.img-img {
			width: 120rpx;
			height: 120rpx;
		}
	}
}
//AG体育显示的数据
.sport-item-contain {
	padding: 20rpx;
	.sport-item-img {
		width: 710rpx;
		height: 246rpx;
	}
}
//真人游戏
.entertainment-item-contain {
	padding: 20rpx;
	.entertainment-item {
		border-bottom: 1px solid #e8e9ec;
	}
	.entertainment-item-img {
		width: 710rpx;
		height: 330rpx;
	}
}
//电子游戏
.ele-banner {
	padding: 20rpx;
	.ele-banner-img {
		width: 710rpx;
		height: 184rpx;
	}
}
.ele-item-contain {
	padding: 20rpx;
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	.ele-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 172rpx;
		height: 200rpx;
		font-size: 28rpx;
		border: 1px solid #e8e9ec;
		.ele-item-img {
			width: 160rpx;
			height: 160rpx;
		}
	}
}

.home-tab-menu {
	display: flex;
	height: 68rpx;
	padding: 4rpx 0rpx;
	.h-t-m-item {
		flex: 1;
		display: block;
		text-align: center;
		font-size: 14px;
		line-height: 30px;
		background: url('/static/img/index_page_tab_bg1.png') repeat-x;
		.h-itme-tit {
			padding: 4px 20px;
			border-radius: 30px;
			background: transparent;
			color: #555;
			margin: 4px auto;
			display: inline;
			font-size: 10px;
		}
		&.active {
			background: url('/static/img/index_page_tab_bg.png') no-repeat center 0rpx;
			.h-itme-tit {
				color: #fff;
				background: linear-gradient(to right, #ffe6e4, #ff938c);
			}
		}
		.item-select-img {
			height: 20px;
			width: 70px;
			margin-top: 8px;
		}
	}
}
// 开元棋牌相关
.ky-banner {
	text-align: center;
	.ky-banner-img {
		width: 730rpx;
		height: 240rpx;
	}
}
.ky-item-contain {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	.ky-item {
		width: 160rpx;
		height: 160rpx;
		margin: 10rpx;
		border-radius: 20rpx;
		border: 1px solid #d0cece;
		display: flex;
		justify-content: center;
		align-items: center;
		.ky-item-img {
			height: 140rpx;
			width: 140rpx;
		}
	}
}
.uni-grid-item {
	border-bottom: 1px solid #e8e9ec;
}
.hot {
	display: none;
	clear: both;
	&.active {
		display: block;
	}
}
.menu-right-border {
	/* #ifdef H5 */
	border-right: 1px solid #e8e9ec;
	/* #endif */
	/* #ifndef H5 */
	.uni-grid-item {
		border-right: 1px solid #e8e9ec;
	}
	/* #endif */
}
</style>
